import request from '@/utils/request';


export const addToCart = (params) => {
    return request.post(`/cart/add`, params)
}

/**
 * 获取购物车列表
 * @param params
 */
export const getCart = () => {
    return request.get(`/cart/getCart`)
}


/**
 * 商品勾选或取消
 * @param params
 */
export const skuChecked = (params) => {
    return request.post(`/cart/sku/checked`, params)
}

/**
 * 批量设置某商家的商品为选中或不选中
 * @param params
 */
export const sellerChecked = (params) => {
    return request.post(`/cart/seller/checked`, params)
}

/**
 * 购物车所有商品选中或不选中
 * @param params
 */
export const allGoodsChecked = (checked) => {
    return request.get(`/cart/all/checked?checked=${checked}`)
}


/**
 * 清空购物车
 * @param params
 */
export const clearCartGoods = () => {
    return request.get(`/cart/clearCart`)
}

/**
 * 删除购物车中的商品
 * @param params
 */
export const delCartGoods = (id) => {
    return request.get(`/cart/delCartGoods?goodsId=${id}`)
}

/**
 * 批量删除购物车中的商品
 * @param params
 */
export const batchDelCartGoods = (ids) => {
    return request.get(`/cart/batchDelCartGoods?goodsIds=${ids}`)
}

export const cartGoodsChecked = (params) => {
    return request.post(`/cart/cartGoodsChecked`, params)
}


/**
 * 检查购物车中是否有该商品
 * @param params
 */
export const checkCartExist = (id) => {
  return request.get(`/cart/checkCartExist?goodsId=${id}`)
}
